package com.baidu.sensitivewordfiltering.controller;

import com.baidu.sensitivewordfiltering.service.SensitiveWordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Set;

@RequestMapping("/word")
@Controller
public class SensitiveWordController {

    @Autowired
    private SensitiveWordService sensitiveWordService;
    /**
     * 敏感词过滤
     *
     * @param text
     * @return
     */
    @RequestMapping("/filter")
    @ResponseBody
    public String sensitiveWordFiltering(String text) {
        Set<String> strings = sensitiveWordService.sensitiveWordFiltering(text);
        return strings.toString();
    }

    @RequestMapping("/replace")
    @ResponseBody
    public String  replaceSensitiveWords(String text){
        String strings =sensitiveWordService.replaceSensitiveWords(text);
        return strings;
    }
}
